package com.ruoyi.admin.service.document;

import com.ruoyi.admin.domain.LlmDocuments;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * 数据库数据处理队列
 * 最多处理5条数据，处理完一组后才让第二组进入
 */


public class ProcessorQueueService {

    private static final BlockingQueue<LlmDocuments> queue = new LinkedBlockingQueue<>();


    /**
     * 添加到全局队列
     */
    public static boolean addLlmDocumentQueue(LlmDocuments documents) {
        return queue.offer(documents);
    }

    public static LlmDocuments getLlmDocumentQueue() throws InterruptedException {
        return queue.take();
    }

    /**
     * 获取队列大小
     */
    public int getQueueSize() {
        return queue.size();
    }

    /**
     * 检查是否有待处理数据
     */
    public boolean hasPendingData() {
        return !queue.isEmpty();
    }


}
